package com;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "twoServlet")
public class twoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        student stu=new student("小李",20);
        request.setAttribute("key",stu);
        request.setAttribute("name","请求");
        HttpSession session=request.getSession();
        session.setAttribute("name","会话");
        ServletContext servletContext=request.getServletContext();
        servletContext.setAttribute("name","全局");
        request.getRequestDispatcher("/index1.jsp").forward(request,response);
    }
}
